import time

import MOGRO
import MOLSO
import db
import config

# 按间距中的绿色按钮以运行脚本。
import file1

if __name__ == '__main__':
    exp_data = []
    # 准备实验数据
    classrooms = db.init_classroom()
    classroom_tavel = db.init_classroomDistance()
    classroom_unavailable_time = db.init_classroom_unavailable_time()
    course_students = db.init_courses_tudents()
    tasks = db.init_task()
    task_room = db.init_task_room()
    task_time = db.init_task_time()
    distribution_required = db.init_constraint_required()
    distribution_penalty = db.init_constraint_penalty()

    for _ in range(10):
        start = time.time()
        # 狮群核心算法
        result, ruselt_fit = MOGRO.MOGRO(tasks, task_room, task_time, classrooms,
                                         classroom_unavailable_time, course_students, distribution_required,
                                         distribution_penalty)
        end = time.time()
        total_time = end - start
        # 运行时间
        print(f"运行时间：%.03f seconds" % total_time)
        exp_data.append([config.file[config.tablePreffix_index], ruselt_fit[1], ruselt_fit[2], ruselt_fit[3],
                         ruselt_fit[1] + ruselt_fit[2] + 10 * ruselt_fit[3],total_time])

    file1.save_data(exp_data)
